import request from '@/utils/request'

// 查询报修单列表
export function listRepairApplication(query) {
  return request({
    url: '/ldzl-sb/sb/repair/application/list',
    method: 'get',
    params: query
  })
}

// 查询报修单详细
export function getRepairApplication(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/' + id,
    method: 'get'
  })
}

// 新增报修单
export function addRepairApplication(data) {
  return request({
    url: '/ldzl-sb/sb/repair/application',
    method: 'post',
    data: data
  })
}

// 修改报修单
export function updateRepairApplication(data) {
  return request({
    url: '/ldzl-sb/sb/repair/application',
    method: 'put',
    data: data
  })
}

// 删除报修单
export function delRepairApplication(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/' + id,
    method: 'delete'
  })
}

// 获取设备列表
export function getEquipmentList() {
  return request({
    url: '/ldzl-sb/equipment/list',
    method: 'get'
  })
}

// 获取可用设备列表
export function getAvailableEquipments() {
  return request({
    url: '/ldzl-sb/sb/repair/application/equipment/list',
    method: 'get'
  })
}

// 接单处理
export function acceptRepairApplication(repairId) {
  return request({
    url: '/ldzl-sb/sb/repair/application/accept',
    method: 'post',
    params: { repair_id: repairId }
  })
}

// 取消维修
export function cancelRepairApplication(repairId, reason) {
  return request({
    url: '/ldzl-sb/sb/repair/application/cancel',
    method: 'post',
    params: {
      repair_id: repairId,
      reason: reason
    }
  })
}

// 获取报修单关联的维修单
export function getRelatedRepairOrder(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/related-repair-order/' + id,
    method: 'get'
  })
} 